﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="index.aspx.cs" Inherits="admin_newsSystem_CommonClass_index" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head" runat="Server">
    <script src="/Plugin/jqueryEasyui/jquery.easyui.min.js" type="text/javascript"></script>
    <link href="/Plugin/jqueryEasyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Plugin/jqueryEasyui/themes/icon.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Title" runat="Server">
    系统管理 - 分类管理
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Control" runat="Server">
    <input type="button" value="添加" onclick="AddAlter()" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Content" runat="Server">
    <script language="javascript" type="text/javascript">
        $(function () {

            //只绘制TreeGrid , TreeGrid的数据在Combobox数据加载完成后，初始化选择项目时onSelect中执行，
            $('#tg').treegrid({
                //url: 'Index.aspx?fun=GetClass',
                idField: 'ID',
                treeField: 'Name',
                height: $("#div_list").parent().height() - 31,
                columns: [[
                        { title: '分类名称', field: 'Name', width: 350 },
                        { title: '深度', field: 'Depth', width: 80, align: 'center' },
                        { title: '操作', field: 'Tools', width: 180, align: 'center' }
                    ]]
            });

            //分类类型 数据加载
            $("#iptClsType").combobox({
                valueField: 'ID',
                textField: 'Name',
                url: 'index.aspx?fun=GetClassType',
                onSelect: ClsType_onSelect,
                onLoadSuccess: function () {
                    $("#iptClsType").combobox("select", $("#iptClsType").combobox('getData')[0].ID)
                }
            });

        });

        //按钮“添加”事件
        var AddAlter = function () {
            art.dialog.removeData("editData");
            art.dialog.open('<%=MyUrl.ToAb("~/Admin/newsSystem/CommonClass/") %>Detail.aspx',
                            {
                                title: "添加分类",
                                id: 'AddAlter',
                                lock: true,
                                width: 820,
                                height: 365,
                                close: function () {
                                }
                            });
        };

        //按钮“编辑”事件
        var editItem = function (id) {
            art.dialog.data("editData", $('#tg').treegrid("find", id));
            art.dialog.open('<%=MyUrl.ToAb("~/Admin/newsSystem/CommonClass/") %>Detail.aspx?fun=EditLoad&cid='+id,
                            {
                                title: "分类编辑",
                                id: 'editAlter',
                                lock: true,
                                width: 820,
                                height: 365,
                                close: function () {
                                }
                            });
        };

        //分类选择事件重新加载列表中数据
        var ClsType_onSelect = function (rec) {
            //重新加载数据
            if (rec != undefined && rec != null) {
                $('#tg').treegrid({ url: "Index.aspx?fun=GetClass&type=" + rec.ID });
            } else {
                $('#tg').treegrid("reload");
            }

        }
    </script>
    <div id="div_list" style="margin-top: 5px;">
        <div style="height: 26px; width: 270px;">
            <span>分类类型：</span><input id="iptClsType" class="easyui-combobox" />
        </div>
        <table id="tg" class="easyui-treegrid">
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Foot" runat="Server">
</asp:Content>
